import { DynamicModule, Module, Global } from '@nestjs/common'
import { ConfigService } from './config.service'
import { CONFIG_OPTIONS } from './constants'

export interface ConfigModuleOptions {
    folder: string
}
@Global()
@Module({})
export class ConfigModule {
    static ConfigService: any
    static register(options: ConfigModuleOptions): DynamicModule {
        return {
            module: ConfigModule,
            providers: [
                {
                    provide: CONFIG_OPTIONS,
                    useValue: options
                },
                ConfigService
            ],
            exports: [ConfigService]
        }
    }
}
